Ticker

6/recent/ticker-posts

Python subjective question for competitive exam (6)

Q1.What are the popular Python libraries used in Data analysis?

Some of the popular libraries of Python used for Data analysis are: I. Pandas: Powerful Python Data Analysis Toolkit II. SciKit: This is a machine learning library in Python. III. Seaborn: This is a statistical data visualization library in Python. IV. SciPy: This is an open source system for science, mathematics and engineering implemented in Python.

Q2. How will you execute a Python script in Unix?

To execute a Python script in Unix, we need to have Python executor in Unix environment. In addition to that we have to add following line as the first line in a Python script file. #!/usr/local/bin/python This will tell Unix to use Python interpreter to execute the script.



Q3. What is the difference between append() and extend() functions of a list in Python?br>

In Python, we get a built-in sequence called list. We can call standard functions like append() and extend() on a list. We call append() method to add an item to the end of a list. We call extend() method to add another list to the end of a list. In append() we have to add items one by one. But in extend() multiple items from another list can be added at the same time.

Q4.What is the difference between ‘is’ and ‘==’ in Python?

We use ‘is’ to check an object against its identity. We use ‘==’ to check equality of two objects. E.g. >>> lst = [10,20, 20] >>> lst == lst[:] True >>> lst is lst[:] False

Q5 What is the output of following code in Python?
>>>name=’John Smith’
>>>print name[:5] + name[5:]

Output of this will be John Smith This is an example of Slicing. Since we are slicing at the same index, the first name[:5] gives the substring name upto 5th location excluding 5th location. The name[5:] gives the rest of the substring of name from the 5th location. So we get the full name as output.



Post a Comment

0 Comments